<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var obj = {
            id: 1,
            uname: '小米',
            price: 1000,
        };

        // Object.defineProperty()定义新属性或者修改原有的属性

        Object.defineProperty(obj, 'num', {
            value: 2000,
            enumerable: true,
        })
        Object.defineProperty(obj, 'price', {
            value: 99,
        })
        Object.defineProperty(obj, 'id', {
            // 如果值为false,不允许修改属性值，默认值也是false
            writable: false,
        })
        Object.defineProperty(obj, 'address', {
            value: 'xcvxdvcfbvc',
            // 如果值为false,不允许遍历，默认值也是false
            enumerable: false,
            // 如果值为false,不允许删除这个属性 不允许修改所有（enumerable、writable和configurable）第三个参数里面的特性，默认值也是false
            configurable: false,
        })
        console.log(obj);
        console.log(Object.keys(obj));
        delete obj.address;
        console.log(obj);
        delete obj.uname;
        console.log(obj);
    </script>
</body>
</html>